package com.pipayshop.controller;

import com.pipayshop.entity.ShopHotelRecord;
import com.pipayshop.entity.vo.ResponseVO;
import com.pipayshop.exception.BusinessException;
import com.pipayshop.service.HotelShopHotelRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 记录酒店入住信息表 前端控制器
 * </p>
 *
 * @author zxb
 * @since 2023-08-02
 */
@Api(value = "记录酒店入住信息接口",tags = "记录酒店入住信息接口")
@RestController
@RequestMapping("/pipayshopapi/shop-hotel-record")
@Slf4j
public class HotelShopHotelRecordController {
    @Resource
    private HotelShopHotelRecordService shopHotelRecordService;

    @PostMapping("createShopHotelRecord")
    @ApiOperation("记录酒店入住信息接口")
    private ResponseVO createShopHotelRecord(@RequestBody ShopHotelRecord shopHotelRecord) {
        try {
            log.info("{}",shopHotelRecord);
            boolean result = shopHotelRecordService.createShopHotelRecord(shopHotelRecord);
            if (!result) {
                throw new Exception();
            }
            return ResponseVO.getSuccessResponseVo("record_checkin_info_success");
        }catch (BusinessException e) {
            throw new BusinessException(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
            throw new BusinessException("record_checkin_info_failed_contact_staff");
        }


    }
}
